*replication files: 2012 anes
use "/Users/spencerpiston/Dropbox/Data/ANES/ANES 2012/anes2012LATERELEASESept212014.dta", clear

*govt should guarantee jobs
gen govtguarjobs=guarpr_self
replace govtguarjobs=. if govtguarjobs<1
replace govtguarjobs=((govtguarjobs*(-1))+7)/6

*spending child care
gen childcare=fedspend_child
recode childcare -9=. -8=. 1=1 2=0 3=.5

*govt services (& spending): more or less
*spsrvpr_ssself
gen govtserv=spsrvpr_ssself
replace govtserv=. if govtserv<1
replace govtserv=(govtserv-1)/6

* aid to the poor
tab fedspend_poor
gen aidtopoor = fedspend_poor
recode aidtopoor -9/-8=. 1=1 2=0 3=0.5
label var aidtopoor "1=increased, 0.5=keep same, 0=decrease"

* welfare
tab fedspend_welfare
gen welfare = fedspend_welfare
recode welfare -9/-8=. 1=1 3=0.5 2=0
label var welfare "1=increased, 0.5=keep same, 0=decrease"

*govt provision index
alpha govtguarjobs childcare govtserv aidtopoor welfare, gen(govtprov) item

* white
tab dem_raceeth
gen white = dem_raceeth
recode white -9/-8=. 1=1 2=0 3=0 4=0

* black
tab dem_raceeth
gen black = dem_raceeth
recode black -9/-8=. 1=0 2=1 3=0 4=0

* latino
tab dem_raceeth
gen latino = dem_raceeth
recode latino -9/-8=. 1=0 2=0 3=1 4=0

*less than high school
gen lessthanhs=.
replace lessthanhs=0 if dem_edugroup==2|dem_edugroup==3|dem_edugroup==4|dem_edugroup==5
replace lessthanhs=1 if dem_edugroup==1

*high school only
gen hs=0
replace hs=. if dem_edugroup==-9|dem_edugroup==-2
replace hs=1 if dem_edugroup==2

*some college
gen sc=0
replace sc=. if dem_edugroup==-9|dem_edugroup==-2 
replace sc=1 if dem_edugroup==3

*college plus
gen cp=0
replace cp=. if dem_edugroup==-9|dem_edugroup==-2
replace cp=1 if dem_edugroup==4|dem_edugroup==5 

*weights
*rename the weight variable to eliminate underscore
gen weightfull=weight_full
gen weightftf=weight_ftf
gen weightweb=weight_web

*7 category PID*
generate pid = pid_x
recode pid -2=.
gen pidrep0to1 = (pid-1)/6

* male
tab gender_respondent
gen male = gender_respondent
recode male 2=0

* age
tab dem_agegrp_iwdate
gen age = dem_agegrp_iwdate
recode age -2=.
tab age
gen age0to1 = (age-1)/12

* south
*making state variable into string variable*
encode sample_state, gen(state)
gen south=0
recode south 0=. if state==.
recode south 0=1 if state==2
recode south 0=1 if state==3
recode south 0=1 if state==10
recode south 0=1 if state==11
recode south 0=1 if state==19
recode south 0=1 if state==26
recode south 0=1 if state==28
recode south 0=1 if state==41
recode south 0=1 if state==43
recode south 0=1 if state==44
recode south 0=1 if state==46

* linked fate - white
gen linkw=link_white
recode linkw -9/-1=. 2=0
tab linkw link_white, miss
recode linkw 1=1 if link_whiteamt==1
recode linkw 1=.67 if link_whiteamt==2
recode linkw 1=.33 if link_whiteamt==3|link_whiteamt==-8|link_whiteamt==-9
tab linkw link_white, miss

*linked fate - hispanic
gen linkh=link_hisp
recode linkh -9/-1=. 2=0
tab linkh link_hisp, miss
recode linkh 1=1 if link_hispamt==1
recode linkh 1=.67 if link_hispamt==2
recode linkh 1=.33 if link_hispamt==3|link_hispamt==-8
tab linkh link_hisp, miss

*linked fate - black
gen linkb=link_black
recode linkb -9/-1=. 2=0
tab linkb link_black, miss
recode linkb 1=1 if link_blackamt==1
recode linkb 1=.67 if link_blackamt==2
recode linkb 1=.33 if link_blackamt==3|link_blackamt==-8
tab linkb link_black, miss

* income
tab inc_incgroup_pre
gen income =  inc_incgroup_pre
recode income -9/-8=. -2=.
gen inc0to1 = (income-1)/27

*Online Appendix 4: distribution of government social provision index
twoway hist govtprov if white==1, ///
	graphregion( color(white) ) ///
	percent ///
	fcolor(gray) lcolor(black) /// 
	ylabel(, nogrid) ///
	yscale(titlegap(2) range(0 10)) ///
	xtitle("") ///
	title("White Respondents") ///
	ytitle(Percent of Respondents) ///
	xscale(titlegap(4)) ///
	ylabel(0 "0" 5 "5" 10 "10")
twoway hist govtprov if black==1, ///
	graphregion( color(white) ) ///
	percent ///
	fcolor(gray) lcolor(black) /// 
	ylabel(, nogrid) ///
	yscale(titlegap(2) range(0 10)) ///
	xtitle("") ///
	title("Black Respondents") ///
	ytitle(Percent of Respondents) ///
	xscale(titlegap(4)) ///
	ylabel(0 "0" 5 "5" 10 "10")	
twoway hist govtprov if latino==1, ///
	graphregion( color(white) ) ///
	percent ///
	fcolor(gray) lcolor(black) /// 
	ylabel(, nogrid) ///
	yscale(titlegap(2) range(0 10)) ///
	xtitle("") ///
	title("Latino Respondents") ///
	ytitle(Percent of Respondents) ///
	xscale(titlegap(4)) ///
	ylabel(0 "0" 5 "5" 10 "10")
	
*Figure 3
svyset [pweight=weightfull]
xi: eststo Whites2012: svy, subpop(white): reg govtprov hs sc cp
coefplot (Whites2012, label(Whites)), drop(_cons) xline(0) title("White Respondents") xscale(range(-.25 .05)) xlabel(-.25(.05).05)
graph save graph1, replace
xi: eststo Blacks2012: svy, subpop(black): reg govtprov hs sc cp
coefplot (Blacks2012, label(Blacks)), drop(_cons) xline(0) title("Black Respondents") xscale(range(-.25 .05)) xlabel(-.25(.05).05)
graph save graph2, replace
xi: eststo Latinos2012: svy, subpop(latino): reg govtprov hs sc cp
coefplot (Latinos2012, label(Latinos)), drop(_cons) xline(0) title("Latino Respondents") xscale(range(-.25 .05)) xlabel(-.25(.05).05)
graph save graph3, replace
graph combine graph1.gph graph2.gph graph3.gph, graphregion( color(white) ) title("")

*Online Appendix 5a: govt provision without controls (figure 3 based on this)
svyset [pweight=weightfull]
svy, subpop(white): reg govtprov hs sc cp
svy, subpop(black): reg govtprov hs sc cp
svy, subpop(latino): reg govtprov hs sc cp

*Online Appendix 5b: govt provision with controls
svyset [pweight=weightfull]
svy, subpop(white): reg govtprov hs sc cp pidrep0to1 male age0to1 south
svy, subpop(black): reg govtprov hs sc cp pidrep0to1 male age0to1 south
svy, subpop(latino): reg govtprov hs sc cp pidrep0to1 male age0to1 south

*Online Appendix 5c: govt provision face to face only
svyset [pweight=weightftf]
svy, subpop(if white==1 & mode==1): reg govtprov hs sc cp
svy, subpop(if black==1 & mode==1): reg govtprov hs sc cp
svy, subpop(if latino==1 & mode==1): reg govtprov hs sc cp

*Online Appendix 5d: govt provision internet only
svyset [pweight=weightweb]
svy, subpop(if white==1 & mode==2): reg govtprov hs sc cp
svy, subpop(if black==1 & mode==2): reg govtprov hs sc cp
svy, subpop(if latino==1 & mode==2): reg govtprov hs sc cp

*Online Appendix 5e: same as 5b except controlling for linked fate
svyset [pweight=weightfull]
svy, subpop(white): reg govtprov hs sc cp pidrep0to1 male age0to1 south linkw
svy, subpop(black): reg govtprov hs sc cp pidrep0to1 male age0to1 south linkb
svy, subpop(latino): reg govtprov hs sc cp pidrep0to1 male age0to1 south linkh

*Online Appendix 6: same as Figure 3 except income
svyset [pweight=weightfull]
xi: eststo Whites2012: svy, subpop(white): reg govtprov inc0to1
xi: eststo Blacks2012: svy, subpop(black): reg govtprov inc0to1
xi: eststo Latinos2012: svy, subpop(latino): reg govtprov inc0to1
coefplot (Whites2012, label(Whites)) (Blacks2012, label(Blacks)) (Latinos2012, label(Latinos)), drop(_cons) xline(0) title("")


